<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('产品账单信息列表')" />
    <th:block th:include="include :: select2-css" />

</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>日期：</label>
                                <input type="text" name="dateInfo"/>
                            </li>
<!--                            <li>-->
<!--                                <label>产品ID：</label>-->
<!--                                <input type="text" name="productId"/>-->
<!--                            </li>-->
                            <li>
                                <label>产品名称：</label>
                                <input type="text" name="productName"/>
                            </li>

                            <li>
                                <label>状态：</label>
                                <select class="form-control"  name="status">
                                    <option value="">所有</option>
                                    <option value="0">待确认</option>
                                    <option value="1">待入账</option>
                                    <option value="2">已入账</option>
                                </select>
                            </li>
<!--                            <li>-->
<!--                                <label>系统消耗量：</label>-->
<!--                                <input type="text" name="sysNumber"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>系统消耗金额：</label>-->
<!--                                <input type="text" name="sysAmount"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>单价：</label>-->
<!--                                <input type="text" name="price"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>实际消耗量：</label>-->
<!--                                <input type="text" name="realNumber"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>实际消耗金额 ：</label>-->
<!--                                <input type="text" name="realAmount"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>预付金额：</label>-->
<!--                                <input type="text" name="payAmount"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>现余额：</label>-->
<!--                                <input type="text" name="balanceAmount"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>：</label>-->
<!--                                <input type="text" name="creatorId"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>：</label>-->
<!--                                <input type="text" name="creatorName"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>：</label>-->
<!--                                <input type="text" name="updateId"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                <label>：</label>-->
<!--                                <input type="text" name="updateName"/>-->
<!--                            </li>-->
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
<!--                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="account:billProduct:add">-->
<!--                    <i class="fa fa-plus"></i> 添加-->
<!--                </a>-->
                <a class="btn btn-success" onclick="refreshBill();" >
                    <i class="fa fa-plus"></i> 刷新账单
                </a>
                <span style="color: red">提醒：当日账单下午六点半才能进行申请入账。</span>
<!--                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="account:billProduct:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="account:billProduct:remove">-->
<!--                    <i class="fa fa-remove"></i> 删除-->
<!--                </a>-->
<!--                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="account:billProduct:export">-->
<!--                    <i class="fa fa-download"></i> 导出-->
<!--                </a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
     <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('account:billProduct:edit')}]];
        var removeFlag = [[${@permission.hasPermi('account:billProduct:remove')}]];
        var prefix = ctx + "account/billProduct";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "产品账单信息",
                columns: [
                //     {
                //     checkbox: true
                // },
                // {
                //     field: 'id',
                //     title: '',
                //     visible: false
                // },
                {
                    field: 'dateInfo',
                    title: '账单日期'
                },
                // {
                //     field: 'productId',
                //     title: '产品ID'
                // },
                {
                    field: 'productName',
                    title: '产品名称'
                },
                {
                    field: 'sysNumber',
                    title: '系统消耗量'
                },
                {
                    field: 'sysAmount',
                    title: '系统消耗金额'
                },
                {
                    field: 'price',
                    title: '单价'
                },
                // {
                //     field: 'discountNumber',
                //     title: '折扣'
                // },
                {
                    field: 'realNumber',
                    title: '实际消耗量'
                },
                {
                    field: 'realAmount',
                    title: '实际消耗金额 '
                },
                // {
                //     field: 'payAmount',
                //     title: '预付金额'
                // },
                // {
                //     field: 'balanceAmount',
                //     title: '现余额'
                // },
                {
                    field: 'statusStr',
                    title: '账单状态',
                    // formatter: function (value, row, index){
                    //     var result = value;
                    //     return result;
                    // }
                },
                {
                    field: 'itemAccountName',
                    title: '账户信息'
                },
                // {
                //     field: 'creatorName',
                //     title: ''
                // },
                // {
                //     field: 'updateId',
                //     title: ''
                // },
                // {
                //     field: 'updateName',
                //     title: '操作员'
                // },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];

                        if (row.status == -1) {
                            actions.push('<a class="btn btn-success btn-xs "  onclick="refreshAccountInfo(\'' + row.id +'\')"><i class="fa fa-edit"></i>刷新账户</a> ');
                        }
                        if (row.status == 0){
                            actions.push('<a class="btn btn-success btn-xs ' + editFlag + '"  onclick="xhEnterAccount(\'' + row.id +'\', \''+ row.dateInfo +'\', \''+ row.productName +'\')"><i class="fa fa-edit"></i>申请入账</a> ');
                            actions.push('<a class="btn btn-primary btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        }

                        // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');

                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function refreshBill() {
            var url = prefix + '/refreshBill';
            $.modal.open("刷新账单", url);
        }

        function refreshAccountInfo(id) {
            $.modal.confirm("确定更新账户信息吗？", function() {
                var url = prefix + '/refreshAccountInfo/' + id;
                $.operate.post(url);
            });
        }

        function xhEnterAccount(recordId, dateInfo, productName) {
            // var url = prefix + '/refreshBill';
            // $.modal.open("刷新账单", url);

            var msg = dateInfo + '-' + productName
            $.modal.confirm("确定申请入账该条[" + msg + "]信息吗？", function() {
                var url = prefix + '/applyEnter'
                $.operate.post(url,{recordId: recordId});
            });
        }

    </script>
</body>
</html>